//
//  TransitionAnimationDelegate.m
//  Home
//
//  Created by 曹连华 on 2019/7/3.
//  Copyright © 2019 曹连华. All rights reserved.
//

#import "TransitionAnimationDelegate.h"

@interface TransitionAnimationDelegate ()

@property (nonatomic, strong) TransitionAnimation *transitionAnimation;

@end

@implementation TransitionAnimationDelegate

- (void)updateTransitionAnimation:(nullable TransitionAnimation *)transitionAnimation {
    self.transitionAnimation = transitionAnimation;
}

#pragma mark - UINavigationControllerDelegate - push / pop
- (nullable id <UIViewControllerInteractiveTransitioning>)navigationController:(UINavigationController *)navigationController
                                   interactionControllerForAnimationController:(id <UIViewControllerAnimatedTransitioning>) animationController  {
    return  nil;
}

- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                            animationControllerForOperation:(UINavigationControllerOperation)operation
                                                         fromViewController:(UIViewController *)fromVC
                                                           toViewController:(UIViewController *)toVC {
    if (operation == UINavigationControllerOperationPush) {
        self.transitionAnimation.transitionType = TransitionTypePush;
    } else if (operation == UINavigationControllerOperationPop) {
        self.transitionAnimation.transitionType = TransitionTypePop;
    }
    return self.transitionAnimation;
}

#pragma mark - UIViewControllerTransitioningDelegate - present / dismissed
- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForPresentedController:(UIViewController *)presented
                                                                            presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source {
    self.transitionAnimation.transitionType = TransitionTypePresent;
    return self.transitionAnimation;
}

- (nullable id <UIViewControllerAnimatedTransitioning>)animationControllerForDismissedController:(UIViewController *)dismissed {
    self.transitionAnimation.transitionType = TransitionTypeDismissed;
    return self.transitionAnimation;
}

- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForPresentation:(id <UIViewControllerAnimatedTransitioning>)animator {
    return nil;
}

- (nullable id <UIViewControllerInteractiveTransitioning>)interactionControllerForDismissal:(id <UIViewControllerAnimatedTransitioning>)animator {
    return  nil;
}

- (nullable UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(nullable UIViewController *)presenting sourceViewController:(UIViewController *)source  {
    return nil;
}

- (void)dealloc {
    NSLog(@"TransitionAnimationDelegate - dealloc ");
}

@end
